package cn.edu.ahstu.acm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import cn.edu.ahstu.acm.entity.Classifier;
import cn.edu.ahstu.acm.entity.Problem;

@Repository

public interface ClassifierMapper {
	
	@Select("select * from classifier order by cid")
	public List<Classifier> queryall();
	
	@Select("select cid,title from classifier")
	public List<Classifier> queryAllClassifier();
	@Select("select * from problem left join classifier_problem cp on cp.pid=problem.pid where cid=#{cid}")
	public List<Problem> queryProblemList(Long cid);
	
	@Insert("insert into classifier(cid,title,createTime,modifyTime) values(#{cid},#{title},#{creatTime},#{modifyTime})")
	public void save(Classifier classifier);
	
	@Select("select * from classifier where cid=#{cid}")
	public Classifier query(Long cid);

	@Select("select * from classifier order by cid limit #{offset},#{pageSize}")
	public List<Classifier> queryForList(Object params,
			@Param("offset") Long page, @Param("pageSize") Long pageSize);
	
	@Select("select count(1) from classifier")
	public Long count();

	@Delete("delete from classifier where cid=#{cid}")
	public void delete(Long cid);
}
